package com.xxy.partnermatch.exception;

import com.xxy.partnermatch.model.enums.ErrorCode;
import lombok.Getter;

/**
 * ClassName: BusinessException
 * Package: com.xxy.usercenter.exception
 * Description: 自定义异常类
 *
 * @Author 十一
 * @Create 2024/11/14 16:32
 * @Version 1.0
 */
@Getter
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    private final int code;

    /**
     * 描述信息
     */
    private final String description;

    /**
     * 构造函数
     *
     * @param code        错误码
     * @param message     错误信息
     * @param description 描述信息
     */
    public BusinessException(int code, String message, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    /**
     * 构造函数
     *
     * @param errorCode 错误码
     */
    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

    /**
     * 构造函数
     *
     * @param errorCode   错误码
     * @param description 描述信息
     */
    public BusinessException(ErrorCode errorCode, String description) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = description;
    }

}
